/*
 * @Description: 
 * @Version: 1.0
 * @Autor: laikt
 * @Date: 2021-01-11 13:55:09
 * @LastEditors: laikt
 * @LastEditTime: 2021-01-12 11:07:52
 */
import { Controller, Post,Body, UseGuards, UsePipes, } from '@nestjs/common';
import { TableService } from './table.service';
import { TableDTO ,TableCodeDTO} from './table.dto';
import { Table } from './entity/table.entity';
import { AuthGuard } from '@nestjs/passport'
import { ValidationPipe } from '../../pipe/validation.pipe'
import { ApiTags, ApiBearerAuth, ApiBody } from '@nestjs/swagger'
@Controller('table')
export class TableController {
    constructor(private readonly tableService: TableService){

    }
    @Post('tableColumnSetting')
    async tableColumnSetting(@Body() tableCode: TableCodeDTO){
        console.log(tableCode);
         try {
        const tableColumn  = await this.tableService.findTableColumn(tableCode)
             return {
                 code:200,
                 data:tableColumn,
                 msg:"查询成功"
             }
         } catch (error) {
            return error
         } 

        
    }
    // JWT验证 - Step 1: 用户请求登录
    // @UseGuards(AuthGuard('local')) // 使用 'JWT' 进行验证
    @UsePipes(new ValidationPipe()) // 使用管道验证
    @ApiBody({
        description: '表格列设置',
        type: TableDTO
    })
    @Post('createTableColumn')
    create(@Body() table: TableDTO) {
        console.log('table',table);
        return this.tableService.create(table)
    }

}
